
import java.util.Arrays;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description: 帅哥陈平安
 * User: hp
 * Date: 2024-02-23
 * Time: 17:59
 */
public class Test {
    public static int fun4(int[] array) {
        int[] find = new int[array.length];
        int n = 0;
        int sum = 0;
        for (int i = 0; i < array.length; i++) {
            int count = 0;
            int flag = 1;
            for (int k = 0; k < n; k++) {
                if (find[k] == array[i]) {
                    flag = 0;
                    break;
                }
            }
            if (flag == 1) {
                for (int j = 0; j < array.length; j++) {
                    if (array[i] == array[j]) {
                        count++;
                    }
                }
                if (count < array.length / 2) {
                    find[n++] = array[i];
                }
            }
            if (count > array.length / 2) {
                sum = array[i];
                break;
            }
        }
        return sum;
    }

    public static void main(String[] args) {
        int[] array1={3,2,3};
        int[] array2={2,2,1,1,1,2,2};
        System.out.println(fun4(array1));
        System.out.println(fun4(array2));
    }
/*    public static boolean fun3(int[] array) {
        for(int i = 0; i < array.length - 3; i++) {
            int flag = 1;
            for(int j = i; j < i + 3; j++) {
                if(array[j] % 2 == 0) {
                    flag = 0;
                    break;
                }
                if(flag == 1) {
                    return true;
                }
            }
        }
        return false;
    }

    public static void main(String[] args) {
        int[] array1 = {2,6,4,1};
        int[] array2 = {1,2,34,3,4,5,7,23,12};
        System.out.println(fun3(array1));
        System.out.println(fun3(array2));

    }*/
   /* public static int fun2(int[] array) {
        int num = 0;
        for(int i = 0; i < array.length; i++) {
            num = num^array[i];
        }
        return num;
    }
    public static void main(String[] args) {
        int array1[] = {2,2,1};
        int array2[] = {4,1,2,1,2};
        System.out.println(fun2(array1));
        System.out.println(fun2(array2));

    }*/

 /*   public static void main(String[] args) {
        int[] nums = {2,7,11,15};
        int target = 9;
        for(int i = 0; i < nums.length - 1; i++) {
            for(int j = i; j < nums.length; j++) {
                if(nums[i] + nums[j] == target) {
                    int[] array={i,j};
                    System.out.println(Arrays.toString(array));
                  }
                }
            }
        }*/


    /*public static void fun(int[] array) {
        for (int i = 0; i < array.length - 1; i++) {
            if (array[i] % 2 == 0) {
                for (int j = i + 1; j < array.length; j++) {
                    if (array[j] % 2 != 0) {
                        int tmp = array[j];
                        array[j] = array[i];
                        array[i] = tmp;
                    }
                }
            }
        }
    }
    public static void main(String[] args) {
        int[] array=new int[]{1,2,3,4,5,6};
        fun(array);
        System.out.println(Arrays.toString(array));
    }*/

  /*  public static void transform(int[] array) {
         for(int i = 0; i < array.length; i++) {
             array[i] = array[i] * 2;
         }
    }
    public static void main(String[] args) {
        int[] array={1,2,3};
        System.out.println(Arrays.toString(array));
        transform(array);
        System.out.println(Arrays.toString(array));

    }*/

}
